#ifndef __LOGGER_HPP
#define __LOGGER_HPP

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//日志宏的实现

#define INF 0
#define DBG 1
#define ERR 3
#define DEFAULT_LOG_LEVEL INF

#define LOG(level,format, ... )  do{\
    if(DEFAULT_LOG_LEVEL > level) break;\
    time_t t = time(nullptr);\
    struct tm* lt = localtime(&t);\
    char buf[32] = {0};\
    strftime(buf,31,"%H:%M:%S",lt);\
    fprintf(stdout,"[%s %s:%d] " format "\n",buf,__FILE__,__LINE__, ##__VA_ARGS__);\
}while(0)

#define ILOG(format, ...) LOG(INF,format,##__VA_ARGS__) //普通打印日志
#define DLOG(format, ...) LOG(DBG,format,##__VA_ARGS__) //调试日志
#define ELOG(format, ...) LOG(ERR,format,##__VA_ARGS__) //错误日志

#endif

